package com.heima.apis.fallback;

import com.heima.apis.client.IScheduleClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.schedule.dtos.Task;
import feign.hystrix.FallbackFactory;

public class IScheduleClientFallback implements FallbackFactory<IScheduleClient> {
    @Override
    public IScheduleClient create(Throwable throwable) {
        return new IScheduleClient() {
            @Override
            public ResponseResult addTask(Task task) {
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }

            @Override
            public ResponseResult cancelTask(long taskId) {
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }

            @Override
            public ResponseResult poll(int type, int priority) {
                return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
            }
        };
    }
}
